package com.gears_software.sxdc.dccx.data.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.gears_software.sxdc.dccx.data.model.Cities;
import com.gears_software.sxdc.dccx.data.model.LineInfoModel;
import com.gears_software.sxdc.dccx.ui.view.HistoryItemView;
import com.gears_software.sxdc.dccx.ui.view.HistoryItemView_;
import java.util.List;

/**
 * Created by SunMuran on 2017/7/22.
 * 历史的adpater
 */

public class HistoryAdatpter extends BaseAdapter {
    private Context context;
    private List<LineInfoModel> historyCitiesData;


    public HistoryAdatpter(Context context, List<LineInfoModel> historyCitiesData) {
        this.context = context;
        this.historyCitiesData = historyCitiesData;

    }

    @Override
    public int getCount() {
        return historyCitiesData.size();
    }

    @Override
    public LineInfoModel getItem(int position) {
        return historyCitiesData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        HistoryItemView itemView = null;
        if (convertView == null) {
            itemView = HistoryItemView_.build(context);
        } else {
            itemView = (HistoryItemView) convertView;
        }

        itemView.bind(historyCitiesData.get(position));

        return itemView;
    }
}
